<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/28
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>Title</title>
        <!--引入layui样式文件-->
        <link rel="stylesheet" href="layui/css/layui.css">
    </head>
    <body>

        <div class="layui-form-item">
            <label class="layui-form-label">部门名</label>
            <div class="layui-input-block">
                <input type="text" id="dname"   class="layui-input"
                       style="width: 200px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所在地</label>
            <div class="layui-input-block">
                <input type="text" id="loc"   class="layui-input"
                       style="width: 200px;">
            </div>
        </div>
        <button class="layui-btn layui-btn-normal"
            style="margin-left: 200px;" onclick="save()">保存</button>
    </body>
    <script src="layui/layui.js"></script>
    <script>
        var $;
        layui.use(['jquery'],function(){
            $ = layui.jquery;

        });

        function save(){
            if($("#dname").val()==''||$("#dname").val()==null){
                alert("部门名不能为空");
                return;
            }
            if($("#loc").val()==''||$("#loc").val()==null){
                alert("所在地不能为空");
                return;
            }
            var index = parent.layer.getFrameIndex(window.name);
            window.parent.addDept($("#dname").val(),$("#loc").val());
            parent.layer.close(index);
        }
    </script>
</html>
